package com.stylefeng.guns.modular.model.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.TicketPrice;
import com.stylefeng.guns.modular.model.service.ITicketPriceService;

/**
 * 控制器
 *
 * @author fengshuonan
 * @Date 2018-08-05 12:53:51
 */
@Controller
@RequestMapping("/ticketPrice")
public class TicketPriceController extends BaseController {

    private String PREFIX = "/model/ticketPrice/";

    @Autowired
    private ITicketPriceService ticketPriceService;

    /**
     * 跳转到首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "ticketPrice.html";
    }

    /**
     * 跳转到添加
     */
    @RequestMapping("/ticketPrice_add")
    public String ticketPriceAdd() {
        return PREFIX + "ticketPrice_add.html";
    }

    /**
     * 跳转到修改
     */
    @RequestMapping("/ticketPrice_update/{ticketPriceId}")
    public String ticketPriceUpdate(@PathVariable Integer ticketPriceId, Model model) {
        TicketPrice ticketPrice = ticketPriceService.selectById(ticketPriceId);
        model.addAttribute("item",ticketPrice);
        LogObjectHolder.me().set(ticketPrice);
        return PREFIX + "ticketPrice_edit.html";
    }

    /**
     * 获取列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return ticketPriceService.selectList(null);
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(TicketPrice ticketPrice) {
        ticketPriceService.insert(ticketPrice);
        return SUCCESS_TIP;
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer ticketPriceId) {
        ticketPriceService.deleteById(ticketPriceId);
        return SUCCESS_TIP;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(TicketPrice ticketPrice) {
        ticketPriceService.updateById(ticketPrice);
        return SUCCESS_TIP;
    }

    /**
     * 详情
     */
    @RequestMapping(value = "/detail/{ticketPriceId}")
    @ResponseBody
    public Object detail(@PathVariable("ticketPriceId") Integer ticketPriceId) {
        return ticketPriceService.selectById(ticketPriceId);
    }
}
